#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import random


def view():
    money = int(input("请输入钱数:"))
    nums = int(input("请输入次数:"))
    debug = input("是否debug->T、F:")
    debug = (debug == "T")
    if debug:
        print(money, nums, debug)
    pk(money, nums, debug)


def pk(money, nums, debug):
    # 钱
    mingMoney = money
    hongMoney = money
    # 次数
    ping = 0
    ming = 0
    hong = 0
    while nums > 0:
        nums -= 1
        mingPk = getRandom()
        hongPk = getRandom()
        if debug:
            print("mingPk:" + str(mingPk) + ",hongPk:" + str(hongPk))

        if ((mingPk + 1) % 3 == hongPk) or ((hongPk + 2) % 3 == mingPk):
            ming += 1
            mingMoney += 1
            hongMoney -= 1
        elif mingPk == hongPk:
            ping += 1
        else:
            hong += 1
            mingMoney -= 1
            hongMoney += 1
        if debug:
            print("小明还剩 " + str(mingMoney) + " 钱", "共赢了 " + str(ming) + " 场!")
            print("小红还剩 " + str(hongMoney) + " 钱", "共赢了 " + str(hong) + " 场!")
            print("平手了 " + str(ping) + " 场!")

    print("------------------------最终结果-----------------------")
    print("小明还剩 " + str(mingMoney) + " 钱", "共赢了 " + str(ming) + " 场!")
    print("小红还剩 " + str(hongMoney) + " 钱", "共赢了 " + str(hong) + " 场!")
    print("平手了 " + str(ping) + " 场!")


# 模拟随机出石头剪刀布，1：石头、2：剪刀、3：布
def getRandom(m, n):
    return random.randint(m, n)


# 模拟随机出石头剪刀布，1：石头、2：剪刀、3：布
def getRandom():
    return random.randint(1, 3)


if __name__ == '__main__':
    view()
